(function () {
    'use strict';
    angular.module('MainApp')
        .config(['$ocLazyLoadProvider', function ($ocLazyLoadProvider) {
            $ocLazyLoadProvider.config({
                debug: false
            });
        }])
        .config(['$locationProvider', function ($locationProvider) {
            $locationProvider.html5Mode(true);
        }])
        .config(['storeProvider', function (storeProvider) {
            // Store defaults to localStorage but we can set sessionStorage or cookieStorage.
            storeProvider.setStore('sessionStorage');
        }])
        /*AngularJS v1.3.x workaround for old style controller declaration in HTML*/
        .config(['$controllerProvider', function ($controllerProvider) {
            // this option might be handy for migrating old apps, but please don't use it
            // in new ones!
            $controllerProvider.allowGlobals();
        }])
        /* Setup Routing For All Pages */
        .config(['$urlRouterProvider', function ($urlRouterProvider) {
            // Redirect any unmatched url
            $urlRouterProvider.otherwise('/login');
        }])
        /* 兼容NWJS APP */
        .config(['$compileProvider', function ($compileProvider) {
            $compileProvider.imgSrcSanitizationWhitelist(/^\s*(https?|ftp|file|chrome-extension):|data:image\//);
            $compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|ftp|mailto|file|chrome-extension):/);
        }])
        .config(['$httpProvider', 'jwtOptionsProvider', function Config($httpProvider, jwtOptionsProvider) {
            jwtOptionsProvider.config({
                unauthenticatedRedirectPath: '/login',
                authPrefix: 'JWT ',
                tokenGetter: ['store', function (store) {
                    return store.get('JWT-TOKEN');
                }]
            });

            $httpProvider.interceptors.push('jwtInterceptor');
        }]);
})();